package com.flynn.rock.system.entity;

import com.flynn.rock.enums.system.NoIdentifierType;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@Getter
@Setter
@Entity
@Table(name = "sys_no_identifier")
@EntityListeners(AuditingEntityListener.class)
@NoArgsConstructor
public class SysNoIdentifierEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "no_identifier_id", nullable = false)
    private Long id;

    @Version
    @Column(name = "version")
    private Integer version;

    @Column(name = "identifier")
    private Long identifier;

    /**
     * yyyyMMdd
     */
    @Column(name = "day_time")
    private String dayTime;

    @Column(name = "no_id_type")
    @Enumerated(EnumType.STRING)
    private NoIdentifierType noIdType;

    @CreatedDate
    @Column(name = "create_time")
    private LocalDateTime createTime;

    @LastModifiedDate
    @Column(name = "update_time")
    private LocalDateTime updateTime;

    public SysNoIdentifierEntity(Long identifier, String dayTime, NoIdentifierType noIdType) {
        this.identifier = identifier;
        this.dayTime = dayTime;
        this.noIdType = noIdType;
    }
}
